package com.tbit.uqbike.webmanager.controller;

import com.github.pagehelper.PageInfo;
import com.tbit.uqbike.object.pojo.UserSta;
import com.tbit.uqbike.object.view.JsonResult;
import com.tbit.uqbike.service.business.UserStaService;
import com.tbit.uqbike.webmanager.util.excel.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户统计信息Controller
 *
 * @author jing
 * @date 2021-06-01
 */
@RestController
@RequestMapping("/sta")
public class UserStaController extends BaseController {
    @Autowired
    private UserStaService userStaService;

    /**
     * 查询用户统计信息列表
     */
    @GetMapping("/list")
    public JsonResult list(UserSta userSta) {
        startPage();
        List<UserSta> list = userStaService.selectUserStaList(userSta);
        return JsonResult.ok(list, (int) new PageInfo<>(list).getTotal());
    }

    /**
     * 导出用户统计信息列表
     */
    @GetMapping("/export")
    public JsonResult export(UserSta userSta) {
        List<UserSta> list = userStaService.selectUserStaList(userSta);
        ExcelUtil<UserSta> util = new ExcelUtil<>(UserSta.class);
        return util.exportExcel(list, "用户信用分列表");
    }
}
